#include <windows.h>
// ParIn.cpp: Implement of class 'ParIn'.
//
#include <iostream>	// standard in/out tools
#include <stdio.h>	// file-handling: fscanf, fprintf, FILE-streams
#include <stdlib.h>
#include "ParIn.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction


ParIn::ParIn()
{

}

ParIn::~ParIn()
{

}


///////////////////////////////////////////////////////////////////
// Objects of class 'ParIn'
ParIn program;
ParIn fixation;
ParIn cue;
ParIn gapA;
ParIn real;
ParIn illusory;
ParIn gapB;
ParIn mask;
ParIn window;
ParIn fillMask;

//
ParIn Rotate;
ParIn Translate;
ParIn Flowfield;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get parameters from InFile
void ParIn::ParRead(){
    char ch;
    char waste[80];
    char *infile="Parameter.txt";
    FILE *InFile;

    if((InFile = fopen(infile, "r"))== NULL){
		program.INPUT=false;
	}
    else{
        while(ch!=':'){ fscanf(InFile,"%c",&ch);}// get the data from within
			//screensize
			//viewing distance
			//dot size in degree
			//dot speed in degree
			//timing parameters
			fscanf( InFile, " %u %u", &program.Width, &program.Height);
			fscanf( InFile, "%s %u %u", &waste, &real.Width, &real.Height);
			fscanf( InFile, "%s %u %u", &waste, &real.Time,&program.Time);
			fscanf( InFile, "%s %f %f %f %f", &waste, &Rotate.Speed,&Translate.Speed,&Flowfield.Speed,&program.Speed);
			fscanf( InFile, "%s %f %f %f", &waste, &program.relPositionX, &program.relPositionY,&program.relPositionZ);
			fscanf( InFile, "%s %f", &waste, &program.Thickness);
			fscanf( InFile, "%s %u %u", &waste, &real.PositionX,&real.PositionY);
			fscanf( InFile, "%s %u", &waste, &program.Gap);
			fscanf( InFile, "%s %u", &waste, &fixation.OnOff);
			fscanf( InFile, "%s %f", &waste, &fixation.Thickness);
			fscanf( InFile, "%s %f %f %f", &waste, &fixation.r,&fixation.g,&fixation.b);
			fclose( InFile );	// and close the file after finishing.
			program.INPUT=true;	
	}
}